﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Department_CusParSet]
@deptId int,
@values int,
@typeId int,
@UserId varchar(10),
@UserName nvarchar(30),
@IP varchar(15)
AS
BEGIN
	If @typeId = 1
		Update Department Set ProtectCount=@values,UserId=@UserId,UserName=@UserName,IP=@IP,LastEditDate=GetDate() Where id=@deptId And ProtectCount<>@values
	Else If @typeId = 2
		Update Department Set ProtectDays=@values,UserId=@UserId,UserName=@UserName,IP=@IP,LastEditDate=GetDate() Where id=@deptId And ProtectDays<>@values
	Else If @typeId = 3
		Update Department Set TrackCount=@values,UserId=@UserId,UserName=@UserName,IP=@IP,LastEditDate=GetDate() Where id=@deptId And TrackCount<>@values
	Else
		Update Department Set TrackDays=@values,UserId=@UserId,UserName=@UserName,IP=@IP,LastEditDate=GetDate() Where id=@deptId And TrackDays<>@values

	If @@error <> 0
		Return -1
	Else
		Return 0
END